#include <string>
#include <map> 
#include <iostream>

typedef struct Conf_s {
	int listenPort;
	std::string svrIp;
	int svrPort;
} Conf; 


class Acsvr{
public:
    Acsvr(Conf& conf);
	virtual ~Acsvr();
    
    virtual int startUp();
    virtual int stop();
	virtual int onClientConnection(int fd);
	virtual int onClientDisconnection(int fd);
	
	virtual int onRecvClientMsg(int fd,const std::string& req) const;
    virtual int onRecvServerMsg(int fd,const std::string& rsp) const;
        
private:
    int connectToSvr();
	int openListenPort(); 
    int run(); 
    bool isFdExist(int fd);
    int sendMsgToSvr(int fd, const std::string& msg) const;
    int sendMsgToCli(int fd, const std::string& msg) const; 
    
	int listenPort_;
    std::string svrIp_;
    int svrPort_;
    std::map<int,int> conMap_;    
};

